#!/bin/bash
# PBPK系统安装脚本

echo "=== PBPK建模系统安装和配置 ==="

# 检查Python版本
echo "检查Python环境..."
if command -v python3 &> /dev/null; then
    echo "✓ Python 3已安装"
    python3 --version
else
    echo "✗ Python 3未安装，请先安装Python 3.8+"
    exit 1
fi

# 检查pip
echo "检查pip环境..."
if command -v pip3 &> /dev/null; then
    echo "✓ pip3已安装"
else
    echo "✗ pip3未安装，请先安装pip3"
    exit 1
fi

# 安装依赖包
echo "安装必需的Python包..."
pip3 install numpy pandas scipy matplotlib seaborn PyYAML

# 检查安装结果
if [ $? -eq 0 ]; then
    echo "✓ 依赖包安装成功"
else
    echo "✗ 依赖包安装失败"
    exit 1
fi

# 创建必要的目录
echo "创建必要的目录结构..."
mkdir -p logs output examples data
echo "✓ 目录结构创建完成"

# 设置权限
echo "设置文件权限..."
chmod +x main.py test_system.py

# 运行测试
echo "运行系统测试..."
python3 test_system.py

if [ $? -eq 0 ]; then
    echo "🎉 PBPK建模系统安装和配置完成！"
    echo "使用方法:"
    echo "  python3 main.py --help  # 查看帮助"
    echo "  python3 main.py --config config/example.json  # 运行示例"
else
    echo "⚠️  系统测试失败，请检查错误信息"
fi